import {
  createRouter,
  createWebHistory,
  createWebHashHistory
} from 'vue-router'
import type { RouteRecordRaw } from 'vue-router'

const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    redirect: '/main/findmucis/stylemusic' //重定向
  },
  {
    path: '/main',
    name: 'Main',
    redirect: '/main/findmucis',
    component: () => import('@/views/main/Main.vue'),
    children: [
      {
        path: 'findmucis',
        name: 'findmucis',
        redirect: '/main/findmucis/stylemusic',
        component: () => import('@/views/main/find-music'),
        children: [
          {
            path: 'stylemusic',
            name: 'stylemusic',
            component: () =>
              import('@/views/main/find-music/children/StyleMusic.vue')
          },
          {
            path: 'songslist',
            name: 'songslist',
            component: () =>
              import('@/views/main/find-music/children/SongsList.vue')
          },
          {
            path: 'anchorstation',
            name: 'anchorstation',
            component: () =>
              import('@/views/main/find-music/children/AnchorStation.vue')
          },
          {
            path: 'rankinglist',
            name: 'rankinglist',
            component: () =>
              import('@/views/main/find-music/children/RankingList.vue')
          },
          {
            path: 'singersearch',
            name: 'singersearch',
            component: () =>
              import('@/views/main/find-music/children/SingerSearch.vue')
          },
          {
            path: 'newsmusic',
            name: 'newsmusic',
            component: () =>
              import('@/views/main/find-music/children/NewsMusic.vue')
          }
        ]
      },
      {
        path: 'songsheet:id',
        name: 'songsheet',
        component: () => import('@/views/main/song-sheet')
      },
      {
        path: 'singer:id',
        name: 'singer',
        component: () => import('@/views/main/singer')
      },
      {
        path: 'user:id',
        name: 'user',
        component: () => import('@/views/main/user-detail')
      },
      {
        path: 'anchor',
        name: 'anchor',
        component: () => import('@/views/main/anchor')
      },
      {
        path: 'mvvideo',
        name: 'mvvideo',
        component: () => import('@/views/main/mv-video')
      },
      {
        path: 'nowmusic',
        name: 'nowmusic',
        component: () => import('@/views/main/now-music')
      },
      {
        path: 'friends',
        name: 'friends',
        component: () => import('@/views/main/friends')
      },
      {
        path: 'privatefm',
        name: 'privatefm',
        component: () => import('@/views/main/private-fm')
      },
      {
        path: 'personality',
        name: 'personality',
        component: () => import('@/views/main/personality')
      },
      {
        path: 'mymusic',
        name: 'mymusic',
        component: () => import('@/views/main/my-music')
      },
      {
        path: 'edituser',
        name: 'edituser',
        component: () => import('@/views/main/edituser')
      },
      {
        path: 'videoshow',
        name: 'videoshow',
        component: () => import('@/views/main/video-play')
      },
      {
        path: 'serachmusic:key',
        name: 'serachmusic',
        component: () => import('@/views/main/serach-music')
      }
    ]
  }
]

const router = createRouter({
  // history: createWebHistory(process.env.BASE_URL),
  history: createWebHashHistory(process.env.BASE_URL),
  routes
})

export default router
